package com.example.musicplayer.square;

import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicplayer.R;

public class Square_add extends Activity {
    private SQLiteDatabase ds,dm;
    EditText mid,sshuo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.square_add);

        TextView man_name=(TextView)findViewById(R.id.sq_name);
        TextView man_id=(TextView)findViewById(R.id.sq_id);
        Bundle bundle=this.getIntent().getExtras();
        String manname= bundle.getString("manname");
        String manid= bundle.getString("manid");
        man_name.setText(manname);
        man_id.setText(manid);

    }

    public void btn_cancel(View view){
        this.finish();
//            Intent intent = new Intent(Square_man.this,Square_xq.class);    //收到消息后跳转
//            startActivity(intent);
    }
    public void btn_ok(View view){

        sshuo= (EditText)findViewById(R.id.et_sshuo);
        //连接数据库，使用ContentValues类型来传值
        DBSquare Square = new DBSquare(this);
        ds = Square.getWritableDatabase();
        ContentValues newvalues = new ContentValues();
        Bundle bundle=this.getIntent().getExtras();
        String manname= bundle.getString("manname");
        String manid= bundle.getString("manid");
        newvalues.put("mid",manid);
        newvalues.put("sshuo",sshuo.getText().toString());
        newvalues.put("mname",manname);
        //调用系统方法写入数据库的表中
        ds.insert("Square",null,newvalues);
        Toast.makeText(this,"添加成功",Toast.LENGTH_SHORT).show();
    }





}